
import { defineStore } from "pinia";
export const loginStore = defineStore("login", {
  state: () => {
    return {
      userInfo:JSON.parse(window.sessionStorage.getItem('userInfo') || '{}'),
    };
  },
  actions: {
    // 设置用户信息,添加token
    setUserInfo(payLoad:any) {
      this.userInfo = payLoad
      window.sessionStorage.setItem('userInfo',JSON.stringify(payLoad))
    },
    //删除token
    clearUserInfo(){
      window.sessionStorage.removeItem('userInfo')
    }
  },
});